<!DOCTYPE html>
<html lang="en">
<style>
    ul.group-list li {
        white-space: nowrap;float: left;
        width: 150px; height: 25px;
        padding: 3px 5px;list-style-type: none;
        list-style-position: outside;border: 0px;margin: 0px;
    }
    input[type=checkbox], input[type=radio] {
        display: inline-block;
    }
</style>

{include file="Public/head"}

<body data-type="widgets">
<script src="/assets/js/theme.js"></script>
<div class="am-g tpl-g">

    {include file='Public:header'}
    {include file='Public:menu2'}



    <!-- 内容区域 -->
    <div class="tpl-content-wrapper" >
        <div class="row-content am-cf">
            <div class="row">

                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-head am-cf">
                            <div class="widget-title am-fl">{notempty name="$data"}编辑{else}新增{/notempty}</div>
                            <div class="widget-function am-fr">
                                <a href="javascript:;" class="am-icon-cog"></a>
                            </div>
                        </div>
                        <div class="widget-body am-fr">
                            <form id="roleform" form="submit" class="am-form tpl-form-border-form tpl-form-border-br">
                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">活动名称 </label>
                                    <div class="am-u-sm-3">
                                        <input type="text" class="tpl-form-input" name="title" placeholder="请输入活动名称" value="{notempty name="$data"}{$data.title}{/notempty}">
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">活动时间</label>
                                    <div class="am-u-sm-3">
                                        <input type="text" id="start_time" class="tpl-form-input form-control pull-right" name="activity" value="{notempty name="$data"}{$data.start_time|date='Y-m-d',###} - {$data.end_time|date='Y-m-d',###}{/notempty}" placeholder="请选择活动时间">
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">选择返利</label>
                                    <div class="am-u-sm-2">

                                            {foreach name="rebate" key="k" item="v"}
                                           <label class="am-u-sm-12"> <input name="rebate_id[]" type="checkbox"  value="{$k}" {notempty name="$data"}{if in_array($k,$data.rebate_id)} checked="checked" {/if}{/notempty} />冲{$v.recharge}送{$v.rebate}</label>
                                            {/foreach}

                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">禁用/启用</label>
                                    <div class="am-u-sm-3">
                                        <label class="am-u-sm-3"><input type="radio"  value="0" name="display" {notempty name="$data"}{if $data.display=="0"} checked="checked" {/if}{/notempty}>启用</label>
                                        <label class="am-u-sm-3"><input type="radio"  value="1" name="display" {notempty name="$data"}{if $data.display=="1"} checked="checked" {/if}{/notempty}>禁用</label>
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">活动描述</label>
                                    <div class="am-u-sm-6">
                                        <textarea class="" rows="8" id="user-intro" name="data" placeholder="请输入活动描述">{notempty name="$data"}{$data.data}{/notempty}</textarea>
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <div class="am-u-sm-9 am-u-sm-push-3">
                                        <a onclick="javascript:history.back(-1);" ><input class="btn btn-default" type="reset" value="返回"></a>
                                        {notempty name="$data"}
                                        <input type="hidden" name="id" value="{$data.id}">
                                        {/notempty}
                                        <input class="btn btn-info" type="submit"  value="提交">
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

</body>
{include file='Public:script'}
{include file='Public:validation'}
<link href="/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css">
<script src="/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<script>

    //提交
    function roleSubmit(){
        var form=document.getElementById("roleform");
        var formData=new FormData(form);
        $.ajax({
            url:"{:Url('addData')}",
            type:'POST',
            data:formData,
            async: false,
            cache: false,
            contentType: false, //不设置内容类型
            processData: false, //不处理数据
            success:function(res){
                console.log(res);
                if (res.code != 200) {
                    layer.msg(res.msg, {shade: 0.5, time: 2000,icon: 2});
                    return false;
                }
                layer.msg(res.msg, {shade: 0.5, time: 2000, icon: 1}, function(){
                    window.location.href=document.referrer;

                });
            }
        });

    }


    //选择时间js
    $(document).ready(function() {
        $('#start_time').daterangepicker({
            format:"YYYY-MM-DD",
            singleDatePicker: false,
            showDropdowns: true,
            minDate:'2019-01-01',
            maxDate:'2030-01-01',
            startDate:'2019-01-01',
            showWeekNumbers: true,
            timePicker: false,
            timePickerIncrement: 1,
            timePicker12Hour: true,
            ranges: {
                '今天': [moment(), moment()],
                '昨天': [moment().subtract('days', 1), moment().subtract('days', 1)],
                '最近7天': [moment().subtract('days', 6), moment()],
                '最近30天': [moment().subtract('days', 29), moment()],
                '上一个月': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')]
            },
            opens: 'right',
            buttonClasses: ['btn btn-default'],
            applyClass: 'btn-small btn-primary',
            cancelClass: 'btn-small',
            locale : {
                applyLabel : '确定',
                cancelLabel : '取消',
                fromLabel : '起始时间',
                toLabel : '结束时间',
                customRangeLabel : '自定义',
                daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
                monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
                firstDay : 1
            }
        });
    });
</script>

</html>